<?php
/*
* StiPHPcms, A web Content management System made with PHP/MySQL
* JordSti : jord52@gmail.com
* Version : 0.0.2
*
* Copyright (C) 2009  jord52@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

include "core/tools/lang_import.php";
include "core/tools/cfgStream.php";
include "core/main.php";

$cms = new CMSPage($cms_config);

$cms->initLess();

//Importing the new lang entry
//$lang = new LangEntryImporter('cache/enplus.lang');
//$lang->parseLangFile();
//$lang->import($cms);

//keeping the page execution count
$dt = $cms->sql_query("SELECT * FROM %prefix%visitlog");
$page_counter = new cfgStream('cache/page_counter','int');
while($data = mysql_fetch_array($dt))
{
	$uri = $data['uri'];
	if($page_counter->isVariableExist($uri))
	{
		$page_counter->entry[$uri] += 1;
	}
	else
	{
		$page_counter->addVariable($uri,1);
	}
}
$page_counter->save();

//deleting the table
$cms->sql_query("DROP TABLE %prefix%visitlog");

$cms->sql_query("DROP TABLE %prefix%session");

$cms->sql_query("CREATE TABLE `%prefix%session` (
  `id` int(25) NOT NULL AUTO_INCREMENT,
  `ip` varchar(16) NOT NULL,
  `user_id` int(25) NOT NULL,
  `session_id` varchar(40) NOT NULL,
  `session_data` text NOT NULL,
  `first_timestamp` int(25) NOT NULL,
  `timestamp` int(25) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
");

?>